payon,157,48,0	script	Ally Guide	107,{

    set @npcname$,"[^ff0000Guide^000000]";

    set @max_guild,3;

    mes @npcname$;
    mes "Hi "+strcharinfo(0)+" !";
    if (getcharid(2) == 0) {
        mes "you have no guild lol gtfo";
        close;
    }
    else if (strcharinfo(0) != getguildmaster(getcharid(2))) {
        mes "Sadly you are not the leader of "+getguildname(getcharid(2))+"!";
        close;
    } else {

    mes "Here you can select allies or friendly guilds that can also visit the guild dungeon.";
    mes "Max guilds: "+@max_guild;
    next;
    menu "Add a guild",add_guild,"View added guilds",view_guild,"Nixx :l",-;
    close;
    


add_guild:

    callfunc "castle_check","aldeg_cas01";
    callfunc "castle_check","aldeg_cas02";
    callfunc "castle_check","aldeg_cas03";
    callfunc "castle_check","aldeg_cas04";
    callfunc "castle_check","aldeg_cas05";
    
    callfunc "castle_check","gefg_cas01";
    callfunc "castle_check","gefg_cas02";
    callfunc "castle_check","gefg_cas03";
    callfunc "castle_check","gefg_cas04";
    callfunc "castle_check","gefg_cas05";
    
    callfunc "castle_check","payg_cas01";
    callfunc "castle_check","payg_cas02";
    callfunc "castle_check","payg_cas03";
    callfunc "castle_check","payg_cas04";
    callfunc "castle_check","payg_cas05";
    
    callfunc "castle_check","prtg_cas01";
    callfunc "castle_check","prtg_cas02";
    callfunc "castle_check","prtg_cas03";
    callfunc "castle_check","prtg_cas04";
    callfunc "castle_check","prtg_cas05";

    mes @npcname$;
    mes "Your castles are:";
    set @count,0;
    while (@Castles$[@count] != "") {
        mes @Castles$[@count];
        set @count,@count+1;
    }
    next;
    mes @npcname$;
    mes "Now please add the name of the guild you would like to be able to visit Gdun";
    mes "Be sure to type the damn straight name!";
    input @Guild$;
    next;
    mes @npcname$;
    mes @Guild$+" was added";
    
    set @gID,getcastledata ("aldeg_cas01",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($aldeg_cas01$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $aldeg_cas01$[@counter],@Guild$;
    }
    set @gID,getcastledata ("aldeg_cas02",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($aldeg_cas02$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $aldeg_cas02$[@counter],@Guild$;
    }
    set @gID,getcastledata ("aldeg_cas03",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($aldeg_cas03$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $aldeg_cas03$[@counter],@Guild$;
    }
    set @gID,getcastledata ("aldeg_cas04",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($aldeg_cas04$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $aldeg_cas04$[@counter],@Guild$;
    }
    set @gID,getcastledata ("aldeg_cas05",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($aldeg_cas05$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $aldeg_cas05$[@counter],@Guild$;
    }


    
    set @gID,getcastledata ("gefg_cas01",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($gefg_cas01$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $gefg_cas01$[@counter],@Guild$;
    }
    set @gID,getcastledata ("gefg_cas02",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($gefg_cas02$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $gefg_cas02$[@counter],@Guild$;
    }
    set @gID,getcastledata ("gefg_cas03",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($gefg_cas03$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $gefg_cas03$[@counter],@Guild$;
    }
    set @gID,getcastledata ("gefg_cas04",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($gefg_cas04$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $gefg_cas04$[@counter],@Guild$;
    }
    set @gID,getcastledata ("gefg_cas05",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($gefg_cas05$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $gefg_cas05$[@counter],@Guild$;
    }

    
    set @gID,getcastledata ("payg_cas01",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($payg_cas01$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $payg_cas01$[@counter],@Guild$;
    }
    set @gID,getcastledata ("payg_cas02",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($payg_cas02$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $payg_cas02$[@counter],@Guild$;
    }
    set @gID,getcastledata ("payg_cas03",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($payg_cas03$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $payg_cas03$[@counter],@Guild$;
    }
    set @gID,getcastledata ("payg_cas04",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($payg_cas04$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $payg_cas04$[@counter],@Guild$;
    }
    set @gID,getcastledata ("payg_cas05",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($payg_cas05$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $payg_cas05$[@counter],@Guild$;
    }


    
    set @gID,getcastledata ("prtg_cas01",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($prtg_cas01$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $prtg_cas01$[@counter],@Guild$;
    }
    set @gID,getcastledata ("prtg_cas02",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($prtg_cas02$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $prtg_cas02$[@counter],@Guild$;
    }
    set @gID,getcastledata ("prtg_cas03",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($prtg_cas03$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $prtg_cas03$[@counter],@Guild$;
    }
    set @gID,getcastledata ("prtg_cas04",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($prtg_cas04$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $prtg_cas04$[@counter],@Guild$;
    }
    set @gID,getcastledata ("prtg_cas05",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($prtg_cas05$[@counter] != "") {
            set @counter,@counter+1;
        }
        set $prtg_cas05$[@counter],@Guild$;
    }
    close;
    end;


view_guild:
    mes @npcname$;
    mes "Added Guilds: ";

    set @gID,getcastledata ("aldeg_cas01",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($aldeg_cas01$[@counter] != "") {
            mes $aldeg_cas01$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("aldeg_cas02",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($aldeg_cas02$[@counter] != "") {
            mes $aldeg_cas02$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("aldeg_cas03",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($aldeg_cas03$[@counter] != "") {
            mes $aldeg_cas03$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("aldeg_cas04",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($aldeg_cas04$[@counter] != "") {
            mes $aldeg_cas04$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("aldeg_cas05",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($aldeg_cas05$[@counter] != "") {
            mes $aldeg_cas05$[@counter];
            set @counter,@counter+1;
        }
    }


    
    set @gID,getcastledata ("gefg_cas01",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($gefg_cas01$[@counter] != "") {
            mes $gefg_cas01$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("gefg_cas02",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($gefg_cas02$[@counter] != "") {
            mes $gefg_cas02$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("gefg_cas03",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($gefg_cas03$[@counter] != "") {
            mes $gefg_cas03$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("gefg_cas04",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($gefg_cas04$[@counter] != "") {
            mes $gefg_cas04$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("gefg_cas05",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($gefg_cas05$[@counter] != "") {
            mes $gefg_cas05$[@counter];
            set @counter,@counter+1;
        }
    }

    
    set @gID,getcastledata ("payg_cas01",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($payg_cas01$[@counter] != "") {
            mes $payg_cas01$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("payg_cas02",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($payg_cas02$[@counter] != "") {
            mes $payg_cas02$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("payg_cas03",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($payg_cas03$[@counter] != "") {
            mes $payg_cas03$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("payg_cas04",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($payg_cas04$[@counter] != "") {
            mes $payg_cas04$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("payg_cas05",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($payg_cas05$[@counter] != "") {
            mes $payg_cas05$[@counter];
            set @counter,@counter+1;
        }
    }


    
    set @gID,getcastledata ("prtg_cas01",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($prtg_cas01$[@counter] != "") {
            mes $prtg_cas01$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("prtg_cas02",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($prtg_cas02$[@counter] != "") {
            mes $prtg_cas02$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("prtg_cas03",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($prtg_cas03$[@counter] != "") {
            mes $prtg_cas03$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("prtg_cas04",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($prtg_cas04$[@counter] != "") {
            mes $prtg_cas04$[@counter];
            set @counter,@counter+1;
        }
    }
    set @gID,getcastledata ("prtg_cas05",1);
    if (@gID == getcharid(2)) {
        set @counter,0;
        while ($prtg_cas05$[@counter] != "") {
            mes $prtg_cas05$[@counter];
            set @counter,@counter+1;
        }
    }

    close;


}
}


function    script    castle_check    ,{
        set @gID,getcastledata (getarg(0),1);
        set @count,0;
        if (getcharid(2) == @gID) {
            while (@Castles$[@count] != "") {
                set @count,@count+1;
            }
            
            set @Castles$[@count],getarg(0);
            set @count,@count+1;
        }
        set @a_size,getarraysize(@Castles$);
        return;

}